﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChatForum.Domain
{
	public class BusinessLogic
	{
		private IRepository repository;
		public BusinessLogic(IRepository repository)
		{
			this.repository = repository;
		}

		public IEnumerable<User> GetAllUser()
		{
			return AccountLogic.GetAllUser(repository);
		}

		public void RegisterMe(User user)
		{
			AccountLogic.RegisterMe(user, repository);
		}

		public void LogIn(string userId, string password)
		{
			AccountLogic.LogIn(userId, password, repository);
		}

		public void ChangeMyPassword(string userId, string oldPassword, string newPassword)
		{
			AccountLogic.ChangeMyPassword(userId, oldPassword, newPassword, repository);
		}

		public void BlockUser(User user)
		{
			AccountLogic.BlockUser(user, repository);
		}

		public void UnblockUser(User user)
		{
			AccountLogic.UnblockUser(user, repository);
		}

		public User GetUser(string userId)
		{
			return AccountLogic.GetUser(userId, repository);
		}

		public void ModifyAccount(User user)
		{
			AccountLogic.ModifyAccount(user, repository);
		}

		public void Logout(string userId)
		{
			AccountLogic.Logout(userId, repository);
		}

		public void CreateCategory(Category category)
		{
			ForumLogic.CreateCategory(category, repository);
		}

		public void CreatePost(Post post)
		{
			ForumLogic.CreatePost(post, repository);
		}

		public IEnumerable<Category> GetAllCategory()
		{
			return ForumLogic.GetAllCategory(repository);
		}

		public IEnumerable<Post> GetPostbyCategory(Guid categoryId, bool includeChildren)
		{
			return ForumLogic.GetPostbyCategory(categoryId, includeChildren, repository);
		}

		public Post GetPostById(Guid postId)
		{
			return ForumLogic.GetPostById(postId, repository);
		}

		public Category GetCategoryById(Guid catId)
		{
			return ForumLogic.GetCategoryById(catId, repository);
		}

		public IEnumerable<Post> GetPostbyParentPost(Guid parentPostid, bool includeChildren)
		{
			return ForumLogic.GetPostbyParentPost(parentPostid, includeChildren, repository);
		}

		public IEnumerable<Post> GetPostbyCreator(string userId, bool includeChildren)
		{
			return ForumLogic.GetPostbyCreator(userId, includeChildren, repository);
		}
		public IEnumerable<Post> GetThread(Guid PostId)
		{
			return ForumLogic.GetThread(repository, PostId);
		}
		public void ModifyCategory(Category category)
		{
			ForumLogic.ModifyCategory(category, repository);
		}
	}
}
